define(["backbone", "app/model/modelNetPoint", "_template", "jquery", "_queryConditions", "_cartData"],
    function (Backbone, Model, template, $, _qc,_CD) {
    return Backbone.View.extend({
        el: '#floor2',
        events: {
            //"click p.netPoint-name": "chooseNetPoint",
            "click div.netPoint-item": "chooseNetPoint"
        },
        initialize: function (opts) {

        },
        render: function (opts) {
            var scope = this;
            scope.model = new Model();
            var postData = {
                pageno: '1',
                pagesize: '1000',
                deviceid: document.getElementById("defaultDeviceId").value
            };
            if (!!opts && opts.districtid) {
                postData.districtid = opts.districtid;
            } else {
                postData.districtid = 0;
            }
            scope.model.save(postData, {
                success: function (data) {
                    //if (data.success) {
                    var d = data.toJSON();
                    var tData = {
                        ListArea: d.result.ListArea,
                        PageInfo: d.result.PageInfo,
                        areaId: d.districtid,
                        areaNow:d.districtid
                    };
                    var tHtml = template("templateNetPoint", tData);
                    $(scope.el).html(tHtml);
                    scope.showDetail();

            }});
        },
        chooseNetPoint:function(e){
            var $this = $(e.target);
            var scope = this;
            if (e.target.tagName.toLowerCase != 'div') {
                $this = $this.parents(".netPoint-item").eq(0);
            }
            _qc.setNetPoint({
                id: $this.attr("data-id"),
                name: $this.attr("data-name"),
                address:$this.attr("data-address")
            });
            _CD.clear();
            window.location.href = window.location.href.split("#")[0];
        },
        showDetail:function(){
            $("#floor1").hide();
            $("#floor2").show();
        }
    });
});